package com.whmnx.home.ui.adapter;

import com.classic.adapter.BaseAdapterHelper;
import com.classic.adapter.CommonRecyclerAdapter;
import com.whmnx.base.bean.VideoListBean;
import com.whmnx.base.utils.ImageUtil;
import com.whmnx.base.utils.UItils;
import com.whmnx.home.R;
import com.whmnx.home.ui.fragment.GuanZhiFragment2;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * author : huang
 * date   : 2020/10/19 0019 9:17
 * version: 1.0
 * @author Administrator
 */
public class VideoAdapter extends CommonRecyclerAdapter<VideoListBean> {
    GuanZhiFragment2 context;
    public VideoAdapter(GuanZhiFragment2 context) {
        super(context.getActivity(), R.layout.item_video);
        this.context = context;

    }


    @Override
    public void onUpdate(BaseAdapterHelper helper, VideoListBean item, int position) {
        helper.setText(R.id.tv_time, (String) item.getCreateDate().split(" ")[0]);
        ImageUtil.setImage((CircleImageView)helper.getView(R.id.iv), item.getWork_UserInfoImage());
      /*  context.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Bitmap bitmap = UItils.getBitmapFormUrl(item.getWork_Vidoe());
                helper.setImageBitmap(R.id.iv_video,bitmap);
               // ivVideo.setImageBitmap(bitmap);
            }
        });*/

        UItils.loadVideoScreenshot(context.getActivity(),item.getWork_Vidoe(),helper.getView(R.id.iv_video));
       context.alreadyLikeList.add(item.getIsLike() == 1);
    }
}
